package com.vcredit.creditcat.web.app;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.vcredit.creditcat.api.ICreditDiagnoseManager;
import com.vcredit.creditcat.dto.creditdiagnose.ProducItemDiagnoseDto;
import com.vcredit.creditcat.model.Cust;
import com.vcredit.creditcat.util.Utility;
import com.vcredit.creditcat.vo.CommitProductInputVo;
import com.vcredit.creditcat.vo.CreditDiagnoseResultVo;
import com.vcredit.creditcat.vo.JsonResult;

/**
 * 信用诊断
 * 
 * @author zhaoqi01
 *
 */
@RestController
@RequestMapping("/creditDiagnose")
public class CreditDiagnoseController extends BaseCreditCatController {

	@Reference(version = "1.0")
	private ICreditDiagnoseManager creditDiagnoseManager;

	/**
	 * 获取产品的信息诊断信息
	 * @author zhaoqi01
	 * @param input
	 * @param request
	 * @return
	 */
	@RequestMapping("/list")
	public JsonResult<CreditDiagnoseResultVo> list(@RequestBody CommitProductInputVo input,HttpServletRequest request) {
		Cust cust = super.getCust(request);
		if (null == cust) {
			return JsonResult.ErrorResponse("用户未登录");
		}
		String[] productIdStrArr = input.getProductIds().split(",");
		Long[] productIdArr = Utility.strArrToLongArr(productIdStrArr);
		List<ProducItemDiagnoseDto> resultDto = creditDiagnoseManager.list(cust, productIdArr);

		return JsonResult.SuccessResponse(new CreditDiagnoseResultVo(resultDto));
	}
}
